// Flutter imports:
import 'package:flutter/material.dart';

// Project imports:
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:palmf_hid/common/values/values.dart';

Widget inputContainer(
    {TextEditingController? controller,
      TextInputType keyboardType = TextInputType.text,
      String? hintText,
      AlignmentGeometry alignment = Alignment.centerLeft,
      String? title,
      double height = 30,
      List<TextInputFormatter>? inputFormatters,
      bool isPassword = false,
      int? maxLines = 1,
      int? minLines = 1,
      String? counterText = "",
      int? maxLength = TextField.noMaxLength,
      bool autofocus = false,
      TextInputAction textInputAction = TextInputAction.done,
      FocusNode? focusNode,
      required ValueChanged<String> onChange,
      Widget? close}) {
  return Container(
    height: height,
    padding: const EdgeInsets.symmetric(horizontal: 5),
    margin: const EdgeInsets.all(0),
    alignment: alignment,
    decoration: BoxDecoration(
        border: Border.all(
          color: MyColor.c_FFEAEAEA,
          width: 1,
        ),
        borderRadius: BorderRadius.circular(4),
        color: MyColor.c_FFFFFFFF),
    child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
      Text(
        title ?? "",
        style: TextStyle(fontSize: 12, color: MyColor.c_66000000),
      ),
      Expanded(
          child: TextField(
            focusNode: focusNode,
            autofocus: autofocus,
            controller: controller,
            inputFormatters: inputFormatters,
            keyboardType: keyboardType,
            decoration: InputDecoration(
                isCollapsed: true,
                hintText: hintText,
                fillColor: MyColor.c_FF999999,
                hintStyle: const TextStyle(color: Colors.grey, fontSize: 12),
                contentPadding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
                border: InputBorder.none,
                counterText: counterText),
            style: TextStyle(
              color: MyColor.c_99000000,
              fontFamily: "Avenir",
              fontWeight: FontWeight.w400,
              fontSize: 12,
            ),
            maxLines: maxLines,
            maxLength: maxLength,
            minLines: minLines,
            autocorrect: false,
            cursorHeight: 12,
            textInputAction: textInputAction,
            cursorColor: MyColor.account_color,
            onChanged: (res) {
              onChange(res);
            },
            // 自动纠正
            obscureText: isPassword, // 隐藏输入内容, 密码框
          )),
      close ?? const SizedBox()
    ]),
  );
}
